<?php /* Smarty version 2.6.26, created on 2016-09-05 00:19:05
         compiled from Index.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "../Common/head.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<div class="container">
    <button type="button" class="btn btn-default  btn-block" data-toggle="modal" data-target=".bs-example-modal-sm-add">添加学生</button>

    <table class="table table-hover">
        <tr>
            <th>学生编号</th>
            <th>学生姓名</th>
            <th>学生年龄</th>
            <th>学生性别</th>
            <th>操作</th>
        </tr>
        <?php $_from = ($this->_tpl_vars['data']); if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['k'] => $this->_tpl_vars['v']):
?>
        <tr>
            <td><?php echo $this->_tpl_vars['v']['sid']; ?>
</td>
            <td><?php echo $this->_tpl_vars['v']['sname']; ?>
</td>
            <td><?php echo $this->_tpl_vars['v']['age']; ?>
</td>
            <td><?php echo $this->_tpl_vars['v']['sex']; ?>
</td>
            <td>
                <!--<a href="index.php?m=Admin&c=Stu&cid=<?php echo $this->_tpl_vars['v']['cid']; ?>
" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-wrench"></span></a>-->
                <button onclick="edit(this,<?php echo $this->_tpl_vars['v']['sid']; ?>
)" sname="<?php echo $this->_tpl_vars['v']['sname']; ?>
" sex="<?php echo $this->_tpl_vars['v']['sex']; ?>
" age="<?php echo $this->_tpl_vars['v']['age']; ?>
" type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target=".bs-example-modal-sm-edit"><span class="glyphicon glyphicon-check"></span></button>

                <button onclick="del(<?php echo $this->_tpl_vars['v']['sid']; ?>
)" type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target=".bs-example-modal-sm-del"><span class="glyphicon glyphicon-remove"></span></button>
            </td>
        </tr>
        <?php endforeach; endif; unset($_from); ?>

    </table>

</div>
<!--添加学生模态框-->
<form method="post" action="">
    <input type="hidden" class="form-control" name="cid" value="<?php echo $_GET['cid']; ?>
">

    <div class="modal fade bs-example-modal-sm-add "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">添加学生</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="exampleInputEmail1">姓名</label>
                        <input type="text" class="form-control" name="sname" id="exampleInputEmail1" placeholder="请输入">
                    </div>

                    <div class="form-group">
                        <label for="exampleInputEmail1">年龄</label>
                        <input type="text" class="form-control" name="age" id="exampleInputEmail1" placeholder="请输入">
                    </div>


                    <div class="form-group">
                        <label for="exampleInputEmail1">性别</label>
                        男：<input type="radio"  name="sex"  value="男" >
                        女：<input type="radio"  name="sex" id="exampleInputEmail1" value="女">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">返回首页</button>
                    <button type="submit" class="btn btn-primary">添加</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
<!--编辑班级模态框-->
<form method="post" action="index.php?m=Admin&c=Stu&a=edit" id="edit">
    <div class="modal fade bs-example-modal-sm-edit "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">编辑学生</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="sid" value=""/>
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="exampleInputEmail1">姓名</label>
                            <input type="text" class="form-control" name="sname" >
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1">年龄</label>
                            <input type="text" class="form-control" name="age">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputEmail1" name="sex">性别</label>
                            男：<input type="radio"  name="sex" value="男" sex="男">
                            女：<input type="radio"  name="sex"  value="女" sex="女">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">返回首页</button>
                    <button type="submit" class="btn btn-primary">编辑</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
<!--删除-->
<form method="post" action="index.php?m=Admin&c=Stu&a=del" id="del">
    <div class="modal fade bs-example-modal-sm-del "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">删除学生</h4>
                </div>
                <input type="hidden" name="sid" value=""/>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                    <button type="submit" class="btn btn-primary">Yes</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
</body>
</html>
<script type="text/javascript">
    //编辑
    function edit(obj,sid) {
        //获取班级的旧名称
        var sname = $(obj).attr("sname");
        var sex = $(obj).attr("sex");
        var age = $(obj).attr("age");
        $("#edit").find("input[name=sname]").val(sname);
        $("#edit").find("input[name=age]").val(age);
        $("#edit").find("input[sex='"+ sex +"']").attr('checked',true);
        $("#edit").find("input[type=hidden]").val(sid);
        $("#edit").modal('show');
    }
    function del(cid) {
        $("#del").find("input[type=hidden]").val(cid);
        $('#del').modal('show')
    }
</script>











